package com.yy.base.common.dialect;

import org.hibernate.transform.AliasedTupleSubsetResultTransformer;
import java.util.Map;

public class PostgresqlTransformer extends AliasedTupleSubsetResultTransformer {
	public static final PostgresqlTransformer TO_ENTITY_MAP = new PostgresqlTransformer();

	private PostgresqlTransformer() {
	}

	public Object transformTuple(Object[] tuple, String[] aliases) {
		Map result = new MapResult(tuple.length);

		for(int i = 0; i < tuple.length; ++i) {
			String alias = aliases[i];
			if (alias != null) {
				result.put(alias.toUpperCase(), tuple[i]);
			}
		}

		return result;
	}

	public boolean isTransformedValueATupleElement(String[] aliases, int tupleLength) {
		return false;
	}

	private Object readResolve() {
		return TO_ENTITY_MAP;
	}
}
